package com.leesche.netdoll.communication.entity;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.leesche.framework.core.id.Guids;
import com.leesche.framework.core.lang.StringUtil;
import com.leesche.netdoll.communication.Settings.RedisModule;

public class GameStatus {

	private String gameId;
	private String deviceId;
	private Date stime;
	private Date etime;
	private Integer amount;
	private Integer quatity;
	private Integer probability;
	private Integer duration;
	private Integer status;

	public String getGameId() {
		return gameId;
	}

	public void setGameId(String gameId) {
		this.gameId = gameId;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public Date getStime() {
		return stime;
	}

	public void setStime(Date stime) {
		this.stime = stime;
	}

	public Date getEtime() {
		return etime;
	}

	public void setEtime(Date etime) {
		this.etime = etime;
	}

	public Integer getAmount() {
		return amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	public Integer getQuatity() {
		return quatity;
	}

	public void setQuatity(Integer quatity) {
		this.quatity = quatity;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getProbability() {
		return probability;
	}

	public void setProbability(Integer probability) {
		this.probability = probability;
	}

	public Integer getDuration() {
		return duration;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	public static String newId() {
		String date = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
		String gameId = Guids.uuid() + "_" + date;
		return gameId;
	}

	public static String location(String gameId) {
		String loc = StringUtils.EMPTY;

		if (StringUtils.isNotBlank(gameId)) {

			String[] ids = gameId.split("_");

			if (ids != null && ids.length == 2) {
				loc = RedisModule.KEY_GS + "-" + ids[1];
			}
		}

		return loc;
	}
}
